﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net.Http;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UserSystem.Web.Client
{
    public partial class UserLogin : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            UserLogin.Test<CustomerInfo, string>(m => m.UserName);

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = "abc";
            string password = "abc";
            var user = new User() {UserName = userName, Password = password};
            var client = new HttpClient();
            var task = client.PostAsJsonAsync("http://localhost:8109/api/Auth", user);
            this.Title = task.Result.Content.ReadAsAsync<string>().Result;
        }

        public static void Test<TModel, TValue>(Expression<Func<TModel, TValue>> expression)
        {
            expression.GetExpressionText();
            ExpressionHelper.GetExpressionText(expression);
        }
    }
    public class CustomerInfo
    {
        [ChineseDescription("用户名")]
        public string UserName { get; set; }

        [ChineseDescription("密码")]
        public string Password { get; set; }
    }
}